package thread;
//测试线程争夺
public class TestFight {
    public  static int conut = 0; //静态常量
    private synchronized static void adder(){conut++;}

    public static void main(String[] args) throws InterruptedException {
      Thread t1=  new Thread(()->{
            for (int i = 0; i < 10000; i++) {
                adder();
            }
        });

        Thread t2=  new Thread(()->{
            for (int i = 0; i < 10000; i++) {
                adder();
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println("最后的结果是："+conut);
    }
}
